<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>个人中心-账户设置</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <div th:include="includeJs::includeJs"></div>
    <div th:include="includeJs::layui_js"></div>

    <link rel="stylesheet" th:href="@{/css/account/lay-cz.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/common.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/user.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/fileupload.less.css}">

    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/userInfo/common.js}"></script>
    <script type="text/javascript" th:src="@{/js/userInfo/user.js}"></script>
    <style type="text/css">
        .txt235{height:38px;border:1px solid #ccc;}
        .aq1{ float: left;background: url(/img/account/aq1.png) ;}
        .aq2{ float: left;background: url(/img/account/aq2.png) ;}
        .aq3{ float: left;background: url(/img/account/aq3.png) ;}
        a{text-decoration:none;}
    </style>
</head>
<body  >
<!--最上面-->
<link th:replace="includeJs::dingding_header">
<!--第二上面-->
<div style="background-color: white;width: 100%">
    <link th:replace="includeJs::dingding_nav">
</div>
<!--个人中心-->
<div class="wrapper wbgcolor">
    <div class="w1200 personal">
        <!--引入菜单栏-->
        <link th:replace="includeJs::userInfoMenu">
        <!--主要内容-->
        <div class="personal-main">
            <div class="personal-zhsz" style="height: 650px;">
                <h3><i>账户设置</i></h3>
                <div class="personal-level">
                    <span class="wzd">您的账户完整度</span>
                    <i class="aq1 level3" id="aqdj" style="border: none; margin: 37px 0px 0px 20px; height: 17px; background-position: 0px -550px;">
                        <!--<img th:src="@{/img/account/aq3.png}" alt="">-->
                    </i>
                    <span class="state">
                        <span id="aq"></span>
                    </span>
                    <i id="zhwzd" class="markicon fl mt35"></i>
                    <span class="arrow-personal">请尽快完成账户安全设置，以确保您的账户安全</span>
                    <span class="grzxbg icon-personal"></span>
                    <input type="hidden" id="userId" th:value="${user.getId()}"/>
                </div>
                <ul>
                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">昵称</span>
                        <span class="zhsz-span2-gg" th:text="${user.getNickName()}"></span>
                        <span class="zhsz-span3">
                            <a href="javascript:void(0)" id="gg">更改</a>
                        </span>
                    </li>
                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">手机号</span>
                        <span class="zhsz-span2-sjh" th:text="${phone}"></span>
                        <span class="zhsz-span3">
                            <a href="javascript:void(0)" id="ggsj">更改</a>
                        </span>
                    </li>
                    <input type="hidden" value="false" id="authenticationMobile">
                    <li>
                        <input type="hidden" id="name" th:value="${userInfo.getRealName()}">
                        <input type="hidden" id="idCard" th:value="${userInfo.getIdCard()}">
                        <input type="hidden" id="pwd" th:value="${userInfo.getPayPwd()}">
                        <input type="hidden" id="email"  th:value="${user.getEmail()}">

                        <dvi th:if="${userInfo.getRealName()==null || '' == (userInfo.getRealName()) }">
                            <i class="grzxbg p-danger"></i>
                            <span class="zhsz-span1">真实姓名</span>
                            <span class="zhsz-span2-real">未实名</span>
                            <span class="zhsz-span3">
                                <a href="#" id="realSm" >实名</a>
                            </span>
                        </dvi>
                        <dvi th:if="${userInfo.getRealName()!=null && !userInfo.getRealName().equals('') }  ">
                            <i class="grzxbg p-right"></i>
                            <span class="zhsz-span1">真实姓名</span>
                            <span class="zhsz-span2-real" th:text="${realName}" ></span>
                            <span class="zhsz-span3">
                                <!--<a href="#" id="realGG" >更改</a>-->
                            </span>
                        </dvi>
                    </li>
                    <li>
                        <dvi th:if="${userInfo.getIdCard()==null ||userInfo.getIdCard().equals('') }">
                            <i class="grzxbg p-danger"></i>
                            <span class="zhsz-span1">身份认证</span>
                            <span class="zhsz-span2-card">未认证</span>
                            <span class="zhsz-span3">
                                <a href="#" id="cardRz" >认证</a>
                            </span>
                        </dvi>
                        <dvi th:if="${userInfo.getIdCard()!=null && !userInfo.getIdCard().equals('') }  ">
                            <i class="grzxbg p-right"></i>
                            <span class="zhsz-span1">身份认证</span>
                            <span class="zhsz-span2-card" th:text="${idCard}" ></span>
                            <span class="zhsz-span3">
                                <!--<a href="#" id="cardGG" >更改</a>-->
                            </span>
                        </dvi>
                    </li>
                    <li>
                        <div th:if="${userInfo.getPayPwd()==null ||userInfo.getPayPwd().equals('') }">
                            <i class="grzxbg p-danger"></i>
                            <span class="zhsz-span1">交易密码</span>
                            <span class="zhsz-span2-pwd">未设置</span>
                            <span class="zhsz-span3">
                                <a href="#" id="pwdSz">设置</a>
                            </span>
                        </div>

                        <div th:if="${userInfo.getPayPwd()!=null && !userInfo.getPayPwd().equals('') }">
                            <i class="grzxbg p-right"></i>
                            <span class="zhsz-span1">交易密码</span>
                            <input type="hidden" id="payPwd" th:value="${userInfo.getPayPwd()}">
                            <span class="zhsz-span2-pwd" th:text="${payPwd}"></span>
                            <span class="zhsz-span3">
                                <a href="#" id="pwdGG">更改</a>
                            </span>
                        </div>
                    </li>
                    <li>
                        <div th:if="${user.getEmail()==null}">
                            <i class="grzxbg p-danger"></i>
                            <span class="zhsz-span1">电子邮箱</span>
                            <span class="zhsz-span2-email">未设置</span>
                            <span class="zhsz-span3">
                                <a href="#" id="emailSz">设置</a>
                            </span>
                        </div>
                        <div th:if="${user.getEmail()!=null}">
                            <i class="grzxbg p-right"></i>
                            <span class="zhsz-span1">电子邮箱</span>
                            <span class="zhsz-span2-email" th:text="${email}"></span>
                            <span class="zhsz-span3">
                                <a href="#" id="emailGG" >更改</a>
                            </span>
                        </div>

                    </li>
                    <li>
                        <i class="grzxbg p-right"></i>
                        <span class="zhsz-span1">登录密码</span>
                        <span class="zhsz-span2"></span>
                        <span class="zhsz-span3">
                            <a href="javascript:void(0)" id="dlPwd">更改</a>
                        </span>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <!--手机号弹出层-->
    <div id="phoneTcc" style="display: none">
        <div class="layui-form-item" style="margin-top:30px">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" id="phone-sjh" name="title" lay-verify="title" autocomplete="off" placeholder="请输入要更换的手机号" style="width: 60%;"  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">验证码</label>
            <div class="layui-input-inline">
                <input type="tel" name="phone" id="phone-yzm" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-inline ">
            <button class="layui-btn layui-btn-fluid layui-btn-normal" id="fsyzm">发送验证码</button>
        </div>

        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="phone-qd" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>

    <!--  设置真实姓名出层-->
    <div id="realTcc" style="display:none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" id="realm1" name="title" lay-verify="title" autocomplete="off" placeholder="请输入真实姓名" style="width: 80%;" class="layui-input">
                <span style="font-size: 12px;color: #f88048">温馨提示：真实姓名认证后不可更改</span>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="realm1qd1" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
    <!--  更改真实姓名出层-->
    <div id="realTccGG" style="display:none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" id="realm2" name="title" lay-verify="title" autocomplete="off" placeholder="请输入真实姓名" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="realm1qd2" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>

  <!--  设置身份证弹出层-->
    <div id="cardTcc" style="display:none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" id="sfzh" name="title" lay-verify="title" autocomplete="off" placeholder="请输入身份证号" style="width: 80%;" class="layui-input">
                <span style="font-size: 12px;color: #f88048">温馨提示：身份证绑定后后不可更改</span>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="sfzhqd" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
    <!--  设置身份证弹出层-->
    <div id="cardTccGG" style="display:none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" id="sfzhgg" name="title" lay-verify="title" autocomplete="off" placeholder="请输入身份证号" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="sfzhqdgg" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
    <!--  设置密码弹出层-->
    <div id="pwdTcc" style="display:none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">交易密码</label>
            <div class="layui-input-block">
                <input type="text" id="pwd1" name="title" lay-verify="title" autocomplete="off" οnkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入六位数的密码" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="pwdqd1" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
    <!--  设置密码弹出层-->
    <div id="pwdTccGG" style="display:none;">
        <div class="layui-form-item" style="margin-top: 20px">
            <label class="layui-form-label" >旧密码</label>
            <div class="layui-input-block">
                <input type="password" id="pwd2" name="title" lay-verify="title" autocomplete="off" οnkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入六位数的密码" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" id="pwd3" name="title" lay-verify="title" autocomplete="off" οnkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入六位数的密码" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" >
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" id="pwd4" name="title" lay-verify="title" autocomplete="off" οnkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入六位数的密码" style="width: 80%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="pwdqd2" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>

    <!-- 设置邮箱弹出层-->
    <div   id="emailTcc"  style="display: none;">
        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">电子邮箱</label>
            <div class="layui-input-block">
                <input type="email" id="dzyx" name="title" lay-verify="title" autocomplete="off" placeholder="请输入邮箱" style="width: 60%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="yxqd" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
    <!--更改邮箱弹出层-->
    <div   id="emailGGTcc"  style="display: none;">

        <div class="layui-form-item" style="margin-top: 30px;">
            <label class="layui-form-label">电子邮箱</label>
            <div class="layui-input-block">
                <input type="email" id="GGdzyx" name="title" lay-verify="title" autocomplete="off" placeholder="请输入邮箱" style="width: 60%;" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-top: 50px; width: 120px;">
            <div class="layui-input-block">
                <button type="button" id="GGyxqd" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
</div>
<link th:replace="includeJs::userInfoJS">
<script>
    layui.use(['layer','element'], function(){

        var $ = layui.jquery,
            layer = layui.layer,//独立版的layer无需执行这一句
            element = layui.element


        //更改昵称
        $("#gg").click(function () {
            var nc = $(".zhsz-span2-gg").text();
            var input = "<input id='ncgg' class='ncgg'  type='text' onblur='qd()'  value='"+nc+"'/>";
            $(".zhsz-span2-gg").html(input);
        })

        //更改手机号弹出层
        $("#ggsj").click(function () {
            layer.open({
                type: 1,
                title: '更换手机号',
                skin: 'layui-layer-demo', //样式类名
                area: ['600px', '300px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#phoneTcc')
            });
        })

        //发送手机验证码
        $("#fsyzm").click(function () {
             $(this).removeClass("layui-btn-normal")
             $(this).addClass("layui-btn-disabled");
             this.disabled = true;
             var btn = this;
             let $sjh = $("#phone-sjh").val();
             if($sjh==null || $sjh.length==0){
                 layer.msg("请输入手机号",{time:2000,icon:2});
                 $(this).removeClass("layui-btn-disabled")
                 $(this).addClass("layui-btn-normal");
                 this.disabled = false;
                 return ;
             }
             if(!(/^1[3456789]\d{9}$/.test($sjh))){
                 $(this).removeClass("layui-btn-disabled")
                 $(this).addClass("layui-btn-normal");
                 this.disabled = false;
                 layer.msg('手机号码有误，请重填',{time:2000,icon:2});
                 return ;
             }
            var index = layer.load();
             $.ajax({
                 url:"/phoneYzm/"+$sjh,
                 type: "post",
                 dataType:"json",
                 success: function (data) {
                     if(data==0){//
                         layer.msg('验证码发送成功,请查收',{time:2000,icon:1});
                         $(btn).removeClass("layui-btn-normal")
                         $(btn).addClass("layui-btn-disabled ");
                         $(btn).val("60");
                         btn.disabled = true;
                         layer.close(index);
                         let count = 60;
                         let timel = setInterval(function () {
                             $('#fsyzm').text(--count+"s");
                             if(count==0){
                                 $(btn).removeClass("layui-btn-disabled")
                                 $(btn).addClass("layui-btn-normal");
                                 $('#fsyzm').text("发送验证码");
                                 btn.disabled = false;
                                 clearInterval(timel);
                             }
                         },1000)
                         return true;
                     }else if(data==1) {
                         layer.msg('验证码发送失败,请重试',{time:2000,icon:2});
                         layer.close(index);
                         return false;
                     }else if(data==2) {
                         layer.msg('验证码发送失败,已经存在该手机号',{time:3000,icon:2});
                         layer.close(index);
                         return false;
                     }
                 },
                 error:function () {
                     $(btn).removeClass("layui-btn-disabled")
                     $(btn).addClass("layui-btn-normal");
                     btn.disabled = false;
                     layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                     return false;
                 }
             })

        })
        //校验手机验证码
        $("#phone-qd").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;
            let $yzm = $("#phone-yzm").val();
            let $phone = $("#phone-sjh").val();

            if($yzm ==null || $yzm.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg('请填写验证码',{time:2000,icon:2});
                return ;
            }
            if($phone ==null || $phone.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg('请填写手机号',{time:2000,icon:2});
                return ;
            }
            $.ajax({
                url:"/checkYzm/"+$yzm+"/"+$phone,
                type: "post",
                dataType:"json",
                success: function (data) {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    if(data==0){//
                        layer.msg('修改成功,请重新登录',{time:3000,icon:1});
                        setTimeout(()=> {
                            window.location.href="/logout"
                           // window.location.reload();//刷新页面
                        },2000)
                        return true;
                    }else if(data==1) {
                        layer.msg('修改失败,验证错误,请重试',{time:3000,icon:2});
                        return false;
                    }else if(data==2) {
                        layer.msg('验证码错误,请重新发送',{time:3000,icon:2});
                        return false;
                    }
                },
                error:function () {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })

        })

        //设置真实姓名弹出层
        $("#realSm").click(function () {
            layer.open({
                type: 1,
                title: '设置真实姓名',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#realTcc')
            });
        });
        //更改真实姓名证弹出层
        $("#realGG").click(function () {
            layer.open({
                type: 1,
                title: '更改真实姓名',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#realTccGG')
            });
        });
        //设置真实姓名确定
        $("#realm1qd1").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;

            let $realm1 = $("#realm1").val();
            let $userId = $("#userId").val();
            if($realm1 ==null || $realm1.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入姓名",{time:2000,icon:2})
                return;
            }
            if($realm1.length <=2 || $realm1.length >=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入真实姓名",{time:2000,icon:2})
                return;
            }
            $.ajax({
                url:"/realSz/"+$realm1+"/"+$userId,
                type: "post",
                dataType:"json",
                success: function (data) {
                    if(data==0){
                        layer.msg('真实姓名更改成功',{time:2000,icon:1});
                        setTimeout(function () {
                            window.location.reload();
                        },2000)
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                    }else {
                        layer.msg('真实姓名更改失败,请重试',{time:3000,icon:2});
                        setTimeout(function () {
                            window.location.reload();
                        },3000)
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                    }
                },
                error:function () {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })
        });
        //更改真实姓名确定
        $("#realm1qd2").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;
            let $realm2 = $("#realm2").val();
            let $userId = $("#userId").val();
            if($realm2 ==null || $realm2.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入姓名",{time:2000,icon:2})
                return;
            }
            if($realm2.length <=3 || $realm2.length >=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入真实姓名",{time:2000,icon:2})
                return;
            }
            $.ajax({
                url:"/realSz/"+$realm2+"/"+$userId,
                type: "post",
                dataType:"json",
                success: function (data) {

                    if(data==0){
                        layer.msg('真实姓名认证成功',{time:2000,icon:1});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },2000)

                    }else {
                        layer.msg('真实姓名认证失败,请重试',{time:2000,icon:2});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },2000)

                    }
                },
                error:function () {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:2000,icon:2});
                    return false;
                }
            })

        });


       
        //认证身份证弹出层
        $("#cardRz").click(function () {
            let $real = $(".zhsz-span2-real").text();
            if($real =='未实名'){
                layer.msg("请先认证真实姓名",{time:3000,icon:2});
                return;
            }else {
                layer.open({
                    type: 1,
                    title: '绑定身份证号',
                    skin: 'layui-layer-demo', //样式类名
                    area: ['400px', '250px'],
                    closeBtn: 1, //不显示关闭按钮
                    fixed: false, //不固定
                    maxmin: true,
                    shadeClose: true, //开启遮罩关闭
                    content: $('#cardTcc')
                });
            }


        });
        //更改身份证弹出层
        $("#cardGG").click(function () {
            layer.open({
                type: 1,
                title: '更改身份证号',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#cardTcc')
            });

        });
        //认证身份证确定
        $("#sfzhqd").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;
            let $card = $("#sfzh").val();
            let $userId = $("#userId").val();
            if($card ==null || $card.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入身份证号",{time:2000,icon:2})
                return;
            }
            if(!(/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/).test($card)){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("您输入的身份证号码不是有效格式",{time:2000,icon:2});
                return;
            }
            $.ajax({
                url:"/cardSz/"+$card+"/"+$userId,
                type: "post",
                dataType:"json",
                success: function (data) {
                    if(data==0){
                        layer.msg('身份认证成功',{time:2000,icon:1});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },2000)
                    }else {
                        layer.msg('身份认证失败,请重试',{time:3000,icon:2});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },3000)
                    }
                },
                error:function () {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })

        });
        //更改身份证确定
        $("#sfzhqdgg").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;

            let $card = $("#sfzhgg").val();
            let $userId = $("#userId").val();
            if($card ==null || $card.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入身份证号",{time:3000,icon:2})
                return;
            }
            if(!(/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/).test($card)){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("您输入的身份证号码不是有效格式",{time:3000,icon:2});
                return;
            }
            $.ajax({
                url:"/cardSz/"+$card+"/"+$userId,
                type: "post",
                dataType:"json",
                success: function (data) {
                    if(data==0){
                        layer.msg('身份更改成功',{time:2000,icon:1});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },2000)
                    }else {
                        layer.msg('身份认证失败,请重试',{time:2000,icon:2});
                        setTimeout(function () {
                            window.location.reload();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },3000)
                    }
                },
                error:function () {
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })

        });

        //设置交易密码弹出层
        $("#pwdSz").click(function () {
            layer.open({
                type: 1,
                title: '设置交易密码',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#pwdTcc')
            });
        });
        //交易密码确定
        $("#pwdqd1").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;

            let $pwd1 = $("#pwd1").val();
            let $userId = $("#userId").val();
            if($pwd1 ==null || $pwd1.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入密码",{time:2000,icon:2})
                return;
            }
            if($pwd1.length !=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请六位数的密码",{time:2000,icon:2})
                return;
            }
            if( $pwd1.length ==6){
                $.ajax({
                    url:"/pwdSz/"+$pwd1+"/"+$userId,
                    type: "post",
                    dataType:"json",
                    success: function (data) {
                        if(data==0){
                            layer.msg('密码设置成功',{time:2000,icon:1});
                            setTimeout(function () {
                                window.location.reload();
                                $(btn).removeClass("layui-btn-disabled")
                                btn.disabled = false;
                            },2000)
                        }else {
                            layer.msg('密码设置失败,请重试',{time:3000,icon:2});
                            setTimeout(function () {
                                window.location.reload();
                                $(btn).removeClass("layui-btn-disabled")
                                btn.disabled = false;
                            },2000)
                        }
                    },
                    error:function () {
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                        return false;
                    }
                })
            }


        });

        //更改交易密码弹出层
        $("#pwdGG").click(function () {
            layer.open({
                type: 1,
                title: '更改交易密码',
                skin: 'layui-layer-demo', //样式类名
                area: ['450px', '350px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#pwdTccGG')
            });
        });
        //更改交易密码确定
        $("#pwdqd2").click(function () {
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;

            let $payPwd =$("#payPwd").val();
            let $pwd2 = $("#pwd2").val();//旧密码
            let $pwd3 = $("#pwd3").val();//新密码
            let $pwd4 = $("#pwd4").val();//确认新密码
            let $userId = $("#userId").val();
            if($pwd2 ==null || $pwd2.length ==0){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入密码",{time:2000,icon:2})
                return;
            }
            if($pwd2.length !=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请六位数的密码",{time:2000,icon:2})
                return;
            }
            if($pwd3.length !=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请六位数的密码",{time:2000,icon:2})
                return;
            }
            if($pwd4.length !=6){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请六位数的密码",{time:2000,icon:2})
                return;
            }
            if($payPwd != $pwd2){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("旧密码不正确，请重新输入",{time:2000,icon:2})
                return;
            }
            if($pwd3 != $pwd4){
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("新密码不一致，请重新输入",{time:2000,icon:2})
                $("#pwd4").val("");
                return;
            }
            if( $pwd2.length ==6){
                $.ajax({
                    url:"/pwdSz/"+$pwd4+"/"+$userId,
                    type: "post",
                    dataType:"json",
                    success: function (data) {
                        if(data==0){
                            layer.msg('密码设置成功',{time:2000,icon:1});
                            setTimeout(function () {
                                window.location.reload();
                                $(btn).removeClass("layui-btn-disabled")
                                btn.disabled = false;
                            },2000)
                        }else {
                            layer.msg('密码设置失败,请重试',{time:3000,icon:2});
                            setTimeout(function () {
                                window.location.reload();
                                $(btn).removeClass("layui-btn-disabled")
                                btn.disabled = false;
                            },3000)
                        }
                    },
                    error:function () {
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                        return false;
                    }
                })
            }


        });

        //邮箱弹出层
        $("#emailSz").click(function () {
            layer.open({
                type: 1,
                title: '绑定邮箱',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#emailTcc'),
                cancel: function(){//右上角关闭回调
                    $("#GGdzyx").val("");
                }

            });
        })
        //邮箱更改弹出层
        $("#emailGG").click(function () {
            $("#GGdzyx").val("");
            layer.open({
                type: 1,
                title: '更改邮箱',
                skin: 'layui-layer-demo', //样式类名
                area: ['400px', '250px'],
                closeBtn: 1, //不显示关闭按钮
                fixed: false, //不固定
                maxmin: true,
                shadeClose: true, //开启遮罩关闭
                content: $('#emailGGTcc')
            });
        })
        //确定发送邮箱
        $("#yxqd").click(function () {
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;
            let $dzyx = $("#dzyx").val();
            if($dzyx == null || $dzyx.length ==0){
                layer.close(loading);
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入邮箱",{time:2000,icon:2})
                return;
            }
            var reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$");
            if(!reg.test($dzyx)){
                layer.close(loading);
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入正确的邮箱",{time:2000,icon:2})
                return;
            }
            $.ajax({
                url:"/email/"+$dzyx,
                type: "post",
                dataType:"json",
                success: function (data) {
                    if(data==0){
                        layer.close(loading);
                        layer.msg('邮箱发送成功,请查收!',{time:3000,icon:1});
                        $("#GGdzyx").val("");
                        setTimeout(function () {
                            layer.closeAll();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },3100)
                        return ;
                    }else if(data==2){
                        layer.close(loading);
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('邮箱发送失败,该邮箱已经被绑定,请重新输入',{time:3000,icon:2});
                        return ;
                    }else if(data==1) {
                        layer.close(loading);
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('邮箱发送失败,请重试',{time:3000,icon:2});
                        return ;
                    }
                },
                error:function () {
                    layer.close(loading);
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })




        })

        //确定更改发送邮箱
        $("#GGyxqd").click(function () {
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $(this).addClass("layui-btn-disabled")
            this.disabled = true;
            var btn = this;
            let $GGdzyx = $("#GGdzyx").val();
            if($GGdzyx == null || $GGdzyx.length ==0){
                layer.close(loading);
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入邮箱",{time:2000,icon:2})
                return;
            }
            var reg = new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$");
            if(!reg.test($GGdzyx)){
                layer.close(loading);
                $(btn).removeClass("layui-btn-disabled")
                btn.disabled = false;
                layer.msg("请输入正确的邮箱",{time:2000,icon:2})
                return;
            }


           // layer.msg("正在发送中~",{time:5000,icon:1})
            $.ajax({
                url:"/email/"+$GGdzyx,
                type: "post",
                dataType:"json",
                success: function (data) {
                    if(data==0){
                        layer.close(loading);
                        layer.msg('邮箱发送成功,请查收',{time:3000,icon:1});
                        $("#GGdzyx").val("");
                        setTimeout(function () {
                            layer.closeAll();
                            $(btn).removeClass("layui-btn-disabled")
                            btn.disabled = false;
                        },3100)
                        return ;
                    }else if(data==2){
                        layer.close(loading);
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('邮箱发送失败,该邮箱已经被绑定,请重新输入',{time:3000,icon:2});
                        return;
                    }else if(data==1) {
                        layer.close(loading);
                        $(btn).removeClass("layui-btn-disabled")
                        btn.disabled = false;
                        layer.msg('邮箱发送失败,请重试',{time:3000,icon:2});
                        return ;
                    }
                },
                error:function () {
                    layer.close(loading);
                    $(btn).removeClass("layui-btn-disabled")
                    btn.disabled = false;
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })




        })
        //更改登录密码
        $("#dlPwd").click(function () {
            location.href="/forgot"
        })

    })
    //昵称输入框失焦
    function qd() {
        let $ncgg = $("#ncgg").val();
        if($ncgg==null|| $ncgg.length < 2){
            layer.msg('请输入昵称。',{time:2000,icon:2})
            return false;
        }
        if($ncgg==null|| $ncgg.length > 10){
            layer.msg('昵称不能超过10位。',{time:2000,icon:2})
            return false;
        }
        if($ncgg!=null|| $ncgg.length > 3){
            $.ajax({
                url:"/updateName",
                type: "post",
                data:{
                    userId:$("#userId").val(),//用户id
                    Name:$ncgg,//更改后的名字
                },
                dataType:"json",
                success: function (data) {
                    if(data){//更改成功
                        $(".zhsz-span2-gg").empty();//清空标签内的组件
                        $(".zhsz-span2-gg").text($ncgg);
                        $.post("/getUserName",{},function (data) {
                            $("#userName").text(data);
                        },"text");
                        return true;
                    }else {
                        layer.msg('更改失败',{time:3000,icon:2});
                        return false;
                    }
                },
                error:function () {
                    layer.msg('呀呀呀,报错啦',{time:3000,icon:2});
                    return false;
                }
            })
        }
    }
    //只能输入数字
    $(function() {
        $('#pwd1').on('input',function (e) {
            var text = $(this).val().replace(/[^\d]/g,"");
            $(this).val(text);
        })
        $('#pwd2').on('input',function (e) {
            var text = $(this).val().replace(/[^\d]/g,"");
            $(this).val(text);
        })
    })

</script>

<script>
        let $name = $("#name").val();//真实姓名
        let $idCard =$("#idCard").val();//身份证号
        let $pwd =$("#pwd").val();//交易密码
        let $email =$("#email").val();//邮箱
        //console.log($name,$idCard,$pwd,$email)
        var i = 0;

        if($name !='' ){
            i+=1;
        }
        if($pwd != ''){
            i+=1;
        }
        if($email != ''){
            i+=1;
        }
        if($idCard !='' ){
            i+=1;
        }
        //console.log($email)
        //console.log(i)
        if(i==0){
            $("#aqdj").addClass("aq1 level3");
            $("#aq").text("低");
        }
        if(i==1){
            $("#aqdj").removeClass("aq1 level3");
            $("#aqdj").addClass("aq2 level3");
            $("#aq").text("中");
        }
        if(i==2){
            $("#aqdj").removeClass("aq1 level3");
            $("#aqdj").addClass("aq2 level3");
            $("#aq").text("中");
        }
        if(i==3){
            $("#aqdj").removeClass("aq1 level3");
            $("#aqdj").addClass("aq2 level3");
            $("#aq").text("中");
        }
        if(i==4){
            $("#aqdj").removeClass("aq1 level3");
            $("#aqdj").addClass("aq3 level3");
            $("#aq").text("高");
        }



</script>
</body>
</html>
